/*
 * @Author: xuetao 3168581151@qq.com
 * @Date: 2025-01-28
 * @LastEditors: xuetao 3168581151@qq.com
 * @LastEditTime: 2025-02-05
 * @Description: 
 */
import 'package:flutter/material.dart';

// 自定义错误提示弹窗组件
class CustomErrorDialog extends StatelessWidget {
  final String title;
  final String message;

  const CustomErrorDialog({
    Key? key,
    required this.title,
    required this.message,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AnimatedOpacity(
      opacity: 1.0,
      duration: const Duration(milliseconds: 300),
      child: AlertDialog(
        title: Center(
          // 标题居中
          child: Text(
            title,
            style: const TextStyle(
              fontSize: 18, // 更小的字体
              fontWeight: FontWeight.bold, // 加粗
            ),
          ),
        ),
        contentPadding: const EdgeInsets.symmetric(
            horizontal: 24.0, vertical: 10.0), // 重设AlertDialog内容的Padding
        content: Column(
          mainAxisSize: MainAxisSize.min, // 自适应内容高度
          crossAxisAlignment: CrossAxisAlignment.center, // 设置为居中
          children: [
            Center(
              // 使错误信息居中
              child: Text(message),
            ),
          ],
        ),
        actionsPadding:
            const EdgeInsets.symmetric(vertical: 8.0), // 重设操作按钮的上下间距
        actions: <Widget>[
          Center(
            // 按钮居中
            child: Container(
              // 为按钮添加上边框
              decoration: const BoxDecoration(
                border: Border(
                  top: BorderSide(
                    color: Color.fromARGB(255, 189, 186, 186), // 设置上边框颜色
                    width: 1.0, // 设置边框宽度
                  ),
                ),
              ),
              child: SizedBox(
                width: double.infinity, // 按钮占满整个弹窗宽度
                child: TextButton(
                  onPressed: () {
                    Navigator.of(context).pop();
                  },
                  child: const Text('确认'),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
